/*
 * XRays Web Framework
 * 
 * Copyright (C) 2007 rico_g AT users DOT sourceforge DOT net
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License s published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * 
 */

package jp.co.ziro.wikidozan.controller;

import java.util.Hashtable;

import jp.co.ziro.wikidozan.util.Xml;


/**
 * Represents the response of a controller handling a request. A response is
 * basically a mime type and either an {@link Xml} object or an
 * {@link InputStream}.
 * 
 * @author rico_g AT users DOT sourceforge DOT net
 * 
 */
public class ControllerResponse {

	private static final int HTML_JUST_FINE = 0;

	private Xml xml;

	private String templateFile;

	private int errorCode;

	private String resName;

	private String controller;


	protected ControllerResponse(Xml xml, String templateFile, String controller) {
		this.xml = xml;
		this.templateFile = templateFile;
		this.controller = controller;
	}

	public ControllerResponse(int errorCode, String resName) {
		this.errorCode = errorCode;
		this.resName = resName;
	}

	public Xml getXml() {
		return xml;
	}

	protected void setTemplate(String templateFile) {
		this.templateFile = templateFile;
	}

	public String getTemplate() {
		return templateFile;
	}

	public boolean wasError() {
		return errorCode != HTML_JUST_FINE;
	}

	public String getResourceName() {
		return resName;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public String getController() {
		return controller;
	}

}
